/**
 * Created by dev-001 on 2017/2/28.
 * 角色
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const RolerSchema = new Schema({
    name: String,//一年级二班数学老师，一年级二班班主任，一年级年级主任
    school: {
        type: ObjectId,
        ref: 'School'
    },
    subjects: [{
        type: ObjectId,
        ref: 'Subject'
    }],
    menus: [{
        type: ObjectId,
        ref: 'Menu'
    }],
    createdAt: Date,
    updatedAt: Date
});

RolerSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Roler', RolerSchema);